﻿using System.Text;

namespace Vibstudio.X4NET
{
    public class Label
    {
        private readonly string _value;

        private Label(string value)
        {
            _value = value;
        }

        public static Label Create(string value)
        {
            return new Label(value);
        }

        public static Label Create(StringBuilder value)
        {
            return new Label(value.ToString());
        }

        public string WithCode(string code)
        {
            return string.Format("{0} - {1}", code, _value);
        }

        public string Message
        {
            get
            {
                if (_value.Length > 0 && !char.IsPunctuation(_value[_value.Length - 1]))
                {
                    return string.Format("{0}.", _value);
                }

                return _value;
            }
        }

        public override string ToString()
        {
            return _value;
        }
    }
}